<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/8/13
 * Time: 16:04
 */

namespace Modules\Base;


use Houdunwang\WeChat\WeChat;
use Modules\Base\Entities\BaseReply;
use Modules\Weixin\Entities\WxRule;

class Respons
{
	public function handle($data){
		$instance = WeChat::instance('message');
		//关注用户扫描二维码事件
		//通过传递过来的规则数据找到对应的回复内容数据
		$content = json_decode(BaseReply::where('rule_id',$data['id'])->first()->content,true);
		//向用户回复消息
		return $instance->text(array_random($content)['content']);
	}
}